<!DOCTYPE html>












  


<html class="theme-next muse use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">






















<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">

<link rel="stylesheet" href="/css/main.css?v=7.1.2">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.1.2">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.1.2">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.1.2">


  <link rel="mask-icon" href="/images/logo.svg?v=7.1.2" color="#222">







<script id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '7.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false,"dimmer":false},
    back2top: true,
    back2top_sidebar: false,
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="从今天开始我们来写一个美剧自动嗅探下载器， 名为 TVDragon， 为我们提供美剧‘一条龙服务’。 其工作原理是根据已订阅的美剧名称（英文名），自动搜索当天的美剧播放表， 从种子网站搜索 torrent 列表， 筛选，自动下载该种子，接着上传torrent到树莓派的 transmission 上进行bt下载。">
<meta name="keywords" content="爬虫">
<meta property="og:type" content="article">
<meta property="og:title" content="开发一个美剧自动嗅探下载器:TVDragon(上)">
<meta property="og:url" content="https://qimajiang.com/2017/12/16/开发一个美剧自动嗅探下载器-上-/index.html">
<meta property="og:site_name" content="启码匠 - 磨刀霍霍向编程">
<meta property="og:description" content="从今天开始我们来写一个美剧自动嗅探下载器， 名为 TVDragon， 为我们提供美剧‘一条龙服务’。 其工作原理是根据已订阅的美剧名称（英文名），自动搜索当天的美剧播放表， 从种子网站搜索 torrent 列表， 筛选，自动下载该种子，接着上传torrent到树莓派的 transmission 上进行bt下载。">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-06-24T06:11:04.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="开发一个美剧自动嗅探下载器:TVDragon(上)">
<meta name="twitter:description" content="从今天开始我们来写一个美剧自动嗅探下载器， 名为 TVDragon， 为我们提供美剧‘一条龙服务’。 其工作原理是根据已订阅的美剧名称（英文名），自动搜索当天的美剧播放表， 从种子网站搜索 torrent 列表， 筛选，自动下载该种子，接着上传torrent到树莓派的 transmission 上进行bt下载。">





  
  
  <link rel="canonical" href="https://qimajiang.com/2017/12/16/开发一个美剧自动嗅探下载器-上-/">



<script id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>开发一个美剧自动嗅探下载器:TVDragon(上) | 启码匠 - 磨刀霍霍向编程</title>
  












  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">启码匠 - 磨刀霍霍向编程</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <h1 class="site-subtitle" itemprop="description">磨刀霍霍向编程</h1>
      
    
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">

    
    
    
      
    

    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">

    
    
    
      
    

    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
        </li>
      
    </ul>
  

  
    

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://qimajiang.com/2017/12/16/开发一个美剧自动嗅探下载器-上-/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="启码匠">
      <meta itemprop="description" content="学习如磨刀， 需要不断温故。">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="启码匠 - 磨刀霍霍向编程">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">开发一个美剧自动嗅探下载器:TVDragon(上)

              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2017-12-16 00:56:24" itemprop="dateCreated datePublished" datetime="2017-12-16T00:56:24+08:00">2017-12-16</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-06-24 14:11:04" itemprop="dateModified" datetime="2019-06-24T14:11:04+08:00">2019-06-24</time>
              
            
          </span>

          

          
            
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <ul>
<li>从今天开始我们来写一个美剧自动嗅探下载器， 名为 TVDragon， 为我们提供美剧‘一条龙服务’。 其工作原理是根据已订阅的美剧名称（英文名），自动搜索当天的美剧播放表， 从种子网站搜索 torrent 列表， 筛选，自动下载该种子，接着上传torrent到树莓派的 transmission 上进行bt下载。<a id="more"></a>

</li>
</ul>
<h2 id="一、背景"><a href="#一、背景" class="headerlink" title="一、背景"></a>一、背景</h2><p>本人是个美剧爱好者，平时几乎每天都有一部美剧更新，而我每天我要做的事情是上 &lt;zimuzu.tv&gt; 去查看当天的美剧播放表， 然后到&lt;torrentz2.eu&gt;搜索所追美剧的种子， 然后根据清晰度筛选，下载，上传后 transmission 进行资源下载。整个过程虽耗时不长， 但有时当天的美剧有好几部， 而且不一定资源已上传， 这就需要重复上述的步骤了。有时之后就会忘记了， 因此造成晚上下班后才去下载，不能好好的享用“美剧大餐”了。这就是 TVDragon 诞生的背景了。</p>
<h2 id="二、必备条件-材料"><a href="#二、必备条件-材料" class="headerlink" title="二、必备条件(材料)"></a>二、必备条件(材料)</h2><h4 id="若要TVDragon-成功运行，-需要满足以下条件"><a href="#若要TVDragon-成功运行，-需要满足以下条件" class="headerlink" title="若要TVDragon 成功运行， 需要满足以下条件"></a>若要TVDragon 成功运行， 需要满足以下条件</h4><ul>
<li>7x24小时运行的Linux服务器（树莓派）</li>
<li>宽带网络</li>
<li>transmission 软件</li>
<li>PHP7.0+</li>
</ul>
<h2 id="三、APi-分析"><a href="#三、APi-分析" class="headerlink" title="三、APi 分析"></a>三、APi 分析</h2><p>既然我们需要爬取美剧播放表和搜索美剧种子等， 就需要用到<a href="https://www.charlesproxy.com/" target="_blank" rel="noopener">Charles</a>这个抓包神器。关于 Charles 的用法可自行搜索，这里不作描述。</p>
<h4 id="1、许多网站都有美剧的播放表，我选择-lt-zimuzu-tv-gt-上的，而且这里我选用了字幕组IOS非-App-Store-版-app作为抓包目标。"><a href="#1、许多网站都有美剧的播放表，我选择-lt-zimuzu-tv-gt-上的，而且这里我选用了字幕组IOS非-App-Store-版-app作为抓包目标。" class="headerlink" title="1、许多网站都有美剧的播放表，我选择 &lt;zimuzu.tv&gt;上的，而且这里我选用了字幕组IOS非 App Store 版 app作为抓包目标。"></a>1、许多网站都有美剧的播放表，我选择 &lt;zimuzu.tv&gt;上的，而且这里我选用了<a href="http://m.yuyue111.com/app/1223493862?s=rrys" target="_blank" rel="noopener">字幕组IOS非 App Store 版</a> app作为抓包目标。</h4><p>经分析， App 上面的播放表 api 是<a href="https://api1.ousns.net/index.php" target="_blank" rel="noopener">https://api1.ousns.net/index.php</a> ,其需要的参数是</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="string">"accesskey"</span>: <span class="string">"519f9cab85c8059d17544947k36113fd3g"</span>,</span><br><span class="line">  <span class="string">"client"</span>: <span class="string">"1"</span>,</span><br><span class="line">  <span class="string">"g"</span>: <span class="string">"api/v2"</span>,</span><br><span class="line">  <span class="string">"m"</span>: <span class="string">"index"</span>,</span><br><span class="line">  <span class="string">"a"</span>: <span class="string">"tv_schedule"</span>,</span><br><span class="line">  <span class="string">"start"</span>: <span class="string">"2017-12-10"</span>,</span><br><span class="line">  <span class="string">"end"</span>: <span class="string">"2017-12-11"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><code>我们这里只需要改变 start 和 end 的值即可获取不同日期的当天美剧播放列表， 但不包含 end 日期的数据</code></p>
<h5 id="响应内容是"><a href="#响应内容是" class="headerlink" title="响应内容是"></a>响应内容是</h5><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">&#123;</span><br><span class="line">    <span class="string">"status"</span>: <span class="number">1</span>,</span><br><span class="line">    <span class="string">"info"</span>: <span class="string">""</span>,</span><br><span class="line">    <span class="string">"data"</span>: &#123;</span><br><span class="line">        <span class="string">"2017-12-24"</span>: [</span><br><span class="line">            &#123;</span><br><span class="line">                <span class="string">"id"</span>: <span class="string">"35673"</span>,</span><br><span class="line">                <span class="string">"cnname"</span>: <span class="string">"谷中十日"</span>,</span><br><span class="line">                <span class="string">"enname"</span>: <span class="string">"Ten Days In the Valley"</span>,</span><br><span class="line">                <span class="string">"poster"</span>: <span class="string">"http://tu.zmzjstu.com/ftp/2017/1001/88292ec7121c82fd6f432f3509411913.jpg"</span>,</span><br><span class="line">                <span class="string">"season"</span>: <span class="string">"1"</span>,</span><br><span class="line">                <span class="string">"episode"</span>: <span class="string">"7"</span>,</span><br><span class="line">                <span class="string">"play_time"</span>: <span class="string">"2017-12-24"</span>,</span><br><span class="line">                <span class="string">"poster_b"</span>: <span class="string">"http://tu.zmzjstu.com/ftp/2017/1001/b_88292ec7121c82fd6f432f3509411913.jpg"</span>,</span><br><span class="line">                <span class="string">"poster_m"</span>: <span class="string">"http://tu.zmzjstu.com/ftp/2017/1001/m_88292ec7121c82fd6f432f3509411913.jpg"</span>,</span><br><span class="line">                <span class="string">"poster_s"</span>: <span class="string">"http://tu.zmzjstu.com/ftp/2017/1001/s_88292ec7121c82fd6f432f3509411913.jpg"</span></span><br><span class="line">            &#125;</span><br><span class="line">        ]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><code>status=1 表示请求成功。data 字段里的数据就是我们真正需要的，里面包含了每部美剧的中文名、英文名和剧集数量等等</code></p>
<h4 id="2、根据美剧英文名搜索-torrent-种子列表。"><a href="#2、根据美剧英文名搜索-torrent-种子列表。" class="headerlink" title="2、根据美剧英文名搜索 torrent 种子列表。"></a>2、根据美剧英文名搜索 torrent 种子列表。</h4><p>这里选择<a href="https://torrentz2.eu/search" target="_blank" rel="noopener">https://torrentz2.eu/search</a>作为搜索的工具。请求参数很简单：</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="string">"f"</span>: <span class="string">"the+flash+2014+s04e09"</span>,</span><br><span class="line">  <span class="string">"save"</span>: <span class="keyword">true</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>f 表示搜索的关键字，关键字中的空格转变为+或 urlEcode ；例如：the flash 2014 s04e09 搜索时变为：the%2Bflash%2B2014%2Bs04e09；<br>save 表示是否开启安全搜索，默认开启。</p>
<pre><code>
##### 返回结果

![d.png](http://ww4.sinaimg.cn/large/a15b4afegy1fmjw8ki15ij20ya0ba782)

更多的搜索结果可查看
&lt;https://torrentz2.eu/search?f=the%2Bflash%2B2014%2Bs04e09&gt;

#### 3、查看可用的 torrent 列表

经过上面的搜索后， 我们可以选择清晰度较高的一个资源查看其可用的 torrent 下载列表。
选择这个资源&lt;The.Flash.2014.S04E09.720p.HDTV.x264-SVA[rarbg]&gt;，之后可以看到如下的 torrent 列表：

![torrent 列表](http://ww4.sinaimg.cn/large/a15b4afegy1fmjwdvfcswj20yv0j50zn)

这里的 torrent 列表可能每一次都不一致的， 因此需要找一个资源列表最多的站点， 对每个站点都分析其下载 torrent 的按钮元素和事件， 方可自动下载 torrent 文件。

``
这里建议若有 rarbg 站点， 首选这个。大多数情况 rarbg 都会比较快更新资源。

``
更快捷的方法是：根据搜索列表中的 title 中 hash 值解析出 torrent 的真实地址。 规则：
``
http://itorrents.org/torrent/hash 值.torrent
``


### 四、Transmission 远程调用接口
##### 关于树莓派是什么？如何购买树莓派？如何在树莓派安装 transmission等等问题，可自行摸索。这里假设一切条件就绪。

 通过上面的步骤我们已经能够实现自动下载 torrent 文件了。既然这样我们需要把 torrent 文件上传到 Transmission 上进资源下载。&lt;transmission.com&gt;上的文档有说明RPC 的方法， 还推荐了几个比较好的类库。

这里我们使用 PHP 实现的transmission RPC类库, &lt;https://github.com/vohof/transmission&gt;. 

### 五、结束
到这里为止， 我们基本分析了TVDragon 的工作流程和梳理如何实现这些需求，关键之处就是如何分析所需要的目标程序， 拆分各个功能需求， 搜索是否已有类似的类库， 这样可减少我们的前期工作量。调研工作已基本结束， 后面的事情就是如何搭建一个开发框架了。这将在下一盘文章中阐述。









</code></pre>
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      
        
          
        
        <div class="post-tags">
          
            <a href="/tags/爬虫/" rel="tag"># 爬虫</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/11/18/使用 Goutte爬取代理 IP 池/" rel="next" title="使用 Goutte爬取 IP 代理池">
                <i class="fa fa-chevron-left"></i> 使用 Goutte爬取 IP 代理池
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/01/28/开发一个美剧自动嗅探下载器-TVDragon-下/" rel="prev" title="开发一个美剧自动嗅探下载器:TVDragon(下)">
                开发一个美剧自动嗅探下载器:TVDragon(下) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">启码匠</p>
              <div class="site-description motion-element" itemprop="description">学习如磨刀， 需要不断温故。</div>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">34</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              

              
                
                
                <div class="site-state-item site-state-tags">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">47</span>
                    <span class="site-state-item-name">标签</span>
                  
                </div>
              
            </nav>
          

          

          

          

          

          
          

          
            
          
          

        </div>
      </div>

      
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#一、背景"><span class="nav-number">1.</span> <span class="nav-text">一、背景</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#二、必备条件-材料"><span class="nav-number">2.</span> <span class="nav-text">二、必备条件(材料)</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#若要TVDragon-成功运行，-需要满足以下条件"><span class="nav-number">2.0.1.</span> <span class="nav-text">若要TVDragon 成功运行， 需要满足以下条件</span></a></li></ol></li></ol><li class="nav-item nav-level-2"><a class="nav-link" href="#三、APi-分析"><span class="nav-number">3.</span> <span class="nav-text">三、APi 分析</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1、许多网站都有美剧的播放表，我选择-lt-zimuzu-tv-gt-上的，而且这里我选用了字幕组IOS非-App-Store-版-app作为抓包目标。"><span class="nav-number">3.0.1.</span> <span class="nav-text">1、许多网站都有美剧的播放表，我选择 &lt;zimuzu.tv&gt;上的，而且这里我选用了字幕组IOS非 App Store 版 app作为抓包目标。</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#响应内容是"><span class="nav-number">3.0.1.1.</span> <span class="nav-text">响应内容是</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2、根据美剧英文名搜索-torrent-种子列表。"><span class="nav-number">3.0.2.</span> <span class="nav-text">2、根据美剧英文名搜索 torrent 种子列表。</span></a></li></ol></li></div>
            

          </div>
        </div>
      <!--/noindex-->
      

      

    </div>
  </aside>
  


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">启码匠</span>

  

  
</div>


  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.1.2</div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  

  

  
</div>









        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

    

    
  </div>

  

<script>
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>

  
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>


  


  <script src="/js/utils.js?v=7.1.2"></script>

  <script src="/js/motion.js?v=7.1.2"></script>



  
  


  <script src="/js/schemes/muse.js?v=7.1.2"></script>



  
  <script src="/js/scrollspy.js?v=7.1.2"></script>
<script src="/js/post-details.js?v=7.1.2"></script>



  


  <script src="/js/next-boot.js?v=7.1.2"></script>


  

  

  

  


  


  
  <script>
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url).replace(/\/{2,}/g, '/');
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x"></i></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x"></i></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  

  

  

  

  

  

  

  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":true}});</script></body>
</html>
